package br.univas.vperiod.jowey.service;

import org.quartz.CronScheduleBuilder;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;

public class SchedulerTimeReport {
	
	public static void startScheduler() throws Exception{
		JobDetail job = JobBuilder.newJob(CreateTimeReport.class).withIdentity("tarfaJubilo", "group1").build();
		
		Trigger trigger = TriggerBuilder.newTrigger()
			    .withIdentity("trigger3", "group1")
			    .startNow()
			    .withSchedule(CronScheduleBuilder.cronSchedule("0 0 15 1 * ?")) // fire on the 5th day of every month at 15:00
			    .build();
		
		Scheduler scheduler = new StdSchedulerFactory().getScheduler();
		scheduler.start();
		scheduler.scheduleJob(job, trigger);
	}
}
